Public Class DayHocSinh
    Protected aHocSinh As New List(Of HocSinh)
    'property 
    Property _aHocSinh() As List(Of HocSinh)
        Get
            Return Me.aHocSinh
        End Get
        Set(ByVal value As List(Of HocSinh))
            Me.aHocSinh = value
        End Set
    End Property
    'nhap 
    Public Shared Function Nhap() As DayHocSinh
        Dim dhs As New DayHocSinh
        Console.Write("nhap so hoc sinh :")
        Dim n As Integer
        n = Integer.Parse(Console.ReadLine())
        For i As Integer = 0 To n - 1
            Dim hs As New HocSinh
            hs = HocSinh.Nhap()
            dhs.aHocSinh.Add(hs)
        Next
        Return dhs
    End Function
    'xuat
    Public Function Xuat() As String
        Dim str As String = "DANH SACH HOC SINH" & vbCrLf
        If (Me.aHocSinh.Count = 0) Then
            str &= "ko co hoc sinh nao: " & vbCrLf
        Else
            For i As Integer = 0 To Me.aHocSinh.Count - 1

                str &= Me.aHocSinh(i).Xuat() & vbCrLf
            Next
        End If
        Return str
    End Function
    'them hoc sinh
    Public Sub Them(ByVal hs As HocSinh)
        Me.aHocSinh.Add(hs)
    End Sub
    'xoa hoc sinh
    Public Function Xoa(ByVal vitri As Integer) As Boolean
        If (vitri >= 0 And vitri < Me.aHocSinh.Count) Then
            Me.aHocSinh.RemoveAt(vitri)
            Return True
        End If
        Return False
    End Function
    'sua hc sinh
    Public Function Sua(ByVal vitri As Integer, ByVal hs As HocSinh) As Boolean
        If (vitri >= 0 And vitri < Me.aHocSinh.Count) Then
            Me.aHocSinh(vitri) = hs
            Return True
        End If
        Return False
    End Function

End Class
